﻿
Imports std

Namespace coupling
    Public Class coupling(Of keyType, __int64 As _int64, __to_uint32 As _to_uint32(Of keyType))
        Private Class trie_type
            Inherits trie(Of keyType, UInt64, __int64, __to_uint32)
        End Class

        Private Class trie_trie_type
            Inherits trie(Of keyType, trie_type, __int64, __to_uint32)
        End Class

        Private _trie As trie_trie_type = Nothing

        Public Sub New()
            _trie = New trie_trie_type()
        End Sub

        Protected Function train(ByVal first() As keyType, ByVal second() As keyType) As Boolean
            Dim it As trie_trie_type.iterator = Nothing
            it = _trie.find(first)
            If it = _trie.end() Then
                it = _trie.insert(first, New trie_type())
            End If
            it.instance.value(second) += 1
        End Function
    End Class

    Public Class onewayCoupling(Of keyType, __int64 As _int64, __to_uint32 As _to_uint32(Of keyType))
        Inherits coupling(Of keyType, __int64, __to_uint32)
    End Class

    Public Class duplexingCoupling(Of keyType, __int64 As _int64, __to_uint32 As _to_uint32(Of keyType))
        Inherits coupling(Of keyType, __int64, __to_uint32)
    End Class
End Namespace
